Question: 1 -
Which of the following is not correct for virtual function in C++ ?
-
Must be declared in public section of class
-
Virtual function should be accessed using pointers
-
Virtual function can be static.
-
Virtual function is defined in base class
Answer:
Virtual function can be static.
Solution:
Virtual function is can’t be static in C++.
Virtual function is can’t be static in C++.
Question: 2 -
Which of these following members are not accessed by using direct member access operator?
-
Protected
-
Both B & C
-
Public
-
Private
Answer:
Both B & C
Solution:
Because of the access is given to the private and protected, We can’t access them by using direct member access operator.
Because of the access is given to the private and protected, We can’t access them by using direct member access operator.
Question: 3 -
How can we make a class abstract?
-
By declaring it abstract using the static keyword.
-
By making at least one member function as pure virtual function.
-
By declaring it abstract using the virtual keyword.
-
By making all member functions constant
Answer:
By making at least one member function as pure virtual function.
Solution:
We can make a class abstract by making at least one member function as pure virtual function.
We can make a class abstract by making at least one member function as pure virtual function.
Question: 4 -
How many specifiers are present in access specifiers in class?
-
3
-
2
-
4
-
1
Answer:
3
Solution:
There are three types of access specifiers. They are public, protected and private.
There are three types of access specifiers. They are public, protected and private.
Question: 5 -
Which other keywords are also used to declare the class other than class?
-
Object
-
Union
-
Both struct & union
-
Struct
Answer:
Both struct & union
Solution:
Struct and union take the same definition of class but differs in the access techniques.
Struct and union take the same definition of class but differs in the access techniques.